package com.smart.common.idem.config;

import com.smart.common.idem.handler.ApiIdempotentInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

/**
 * @author zhangwei
 */
@Configuration
public class IdempotentWebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptorAdapter());
    }

    @Bean
    public HandlerInterceptorAdapter interceptorAdapter() {
        return new ApiIdempotentInterceptor();
    }

}
